package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/shop")
@Api(tags = "用户端-商铺模块")
@Slf4j
public class UserShopController {

    public static final String Shopkey = "SHOP_STATUS";

    @Autowired
    private RedisTemplate redisTemplate;


    /**
     * 查询商铺状态
     * @return
     */
    @GetMapping("/status")
    @ApiOperation(value = "查询商铺状态")
    public Result<Integer> GetStatus() {

        //查询商铺状态
        Integer status = (Integer) redisTemplate.opsForValue().get(Shopkey);

        log.info("查询商铺状态：{}",status==1 ? "营业中" : "打烊了");

        return Result.success(status);
    }
}
